/* 
 * File:   Singleton.h
 * Author: Zeeno
 *
 * Created on 1. březen 2012, 13:07
 */

#ifndef SINGLETON_H
#define	SINGLETON_H

#include <cstdlib>

namespace vertigo {

    template <class T>
    class Singleton {
    protected:
        volatile static T * _instance;
    
    public:
        static T * instance() {
            if (_instance == NULL)
                _instance = new T();
            return _instance;
        }
        
        static void deleteInstance() {
            if(_instance != NULL){
                delete _instance;
                _instance = NULL;
            }
        }
    };

    template<class T> volatile T * Singleton<T>::_instance = NULL;
}

#endif	/* SINGLETON_H */

